local lsp_xingliun = fk.CreateSkill {
    name = "lsp_xingliun",
    anim_type = "control",
}
Fk:loadTranslationTable {
    ["lsp_xingliun"] = "星鎏",
    [":lsp_xingliun"] = "你可以于以下时机，视为使用一张仅指定一个角色的普通锦囊牌或基本牌，以此法使用的牌无距离和次数限制：<br>" ..
        "①有角色死亡时；<br>" ..
        "②游戏开始时或每轮结束时；<br>" ..
        "③有角色一次回复体力大于1时；<br>" ..
        "④一名角色失去最后一张手牌时；<br>" ..
        "⑤有角色于其当前阶段内使用第二张【杀】后。",

    ["#lsp_xingliun-use"] = "星鎏：请选择要使用的卡牌",
}
local spec = {
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(lsp_xingliun.name)
    end,
    on_cost = function(self, event, target, player, data)
        return player.room:askToSkillInvoke(player, {
            skill_name = lsp_xingliun.name,
            prompt = "星鎏：是否视为使用一张单体锦囊牌或基本牌？",
        })
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local names = {}
        for _, id in ipairs(Fk:getAllCardIds()) do
            local c = Fk:getCardById(id)
            if (c.type == Card.TypeBasic or c:isCommonTrick()) and not c.multiple_targets and not c.is_derived then
                table.insertIfNeed(names, Fk:getCardById(id).name)
            end
        end
        if #names > 0 then
            room:askToUseVirtualCard(player, {
                name = names,
                skill_name = lsp_xingliun.name,
                cancelable = true,
                extra_data = {
                    bypass_times = true,
                    extraUse = true,
                    bypass_distances = true,
                },
                prompt = "#lsp_xingliun-use",
            })
        end
        room:setPlayerMark(player, "lsp_xingliun_slah-phase", 1)
    end,
}
lsp_xingliun:addEffect(fk.RoundEnd, spec)
lsp_xingliun:addEffect(fk.GameStart, spec)
lsp_xingliun:addEffect(fk.Deathed, spec)

lsp_xingliun:addEffect(fk.HpRecover, {
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(lsp_xingliun.name) and data.num > 1
    end,
    on_cost = spec.on_cost,
    on_use = spec.on_use,
})
lsp_xingliun:addEffect(fk.AfterCardsMove, {
    can_trigger = function(self, event, target, player, data)
        if not player:hasSkill(lsp_xingliun.name) then return end
        for _, move in ipairs(data) do
            if move.from and move.from:isKongcheng() then
                for _, info in ipairs(move.moveInfo) do
                    if info.fromArea == Card.PlayerHand then
                        return true
                    end
                end
            end
        end
    end,
    on_cost = spec.on_cost,
    on_use = spec.on_use,
})

lsp_xingliun:addEffect(fk.CardUseFinished, {  --判断其他角色是否使用第二张杀并触发效果
    anim_type = "offensive",
    can_trigger = function(self, event, target, player, data)
        local room = player.room
        if player:hasSkill(lsp_xingliun.name) and data.card.trueName == "slash" and player:getMark("lsp_xingliun_slah-phase") == 0 then
            local events = room.logic:getEventsOfScope(GameEvent.UseCard, 2, function(e)
                local use = e.data
                return use.from == room.current and use.card.trueName == "slash"
            end, Player.HistoryTurn)
            return #events == 2 and events[2].id == room.current.room.logic:getCurrentEvent().id
        end
    end,
    on_cost = spec.on_cost,
    on_use = spec.on_use,
})
return lsp_xingliun
